# Maintainer: Johannes Schindelin <johannes.schindelin@gmx.de>

pkgbase=msgpack-c
pkgname=('msgpack-c' 'msgpack-c-devel')
pkgver=3.3.0
pkgrel=1
pkgdesc="MessagePack implementation for C"
arch=('i686' 'x86_64')
url="https://msgpack.org"
license=('Boost')
makedepends=('cmake')
options=('strip' '!debug')
source=("${pkgbase}"::"git+https://github.com/msgpack/msgpack-c#tag=cpp-$pkgver")
sha256sums=('SKIP')

build() {
  cd "${srcdir}/${pkgbase}"

  cmake -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=None \
    -DBUILD_SHARED_LIBS=ON \
    -DMSGPACK_ENABLE_STATIC=OFF \
    -DMSGPACK_CXX11=ON \
    -DMSGPACK_BUILD_EXAMPLES=OFF \
    .

  make
  make DESTDIR="${srcdir}/dest" install
}

package_msgpack-c() {
  pkgdesc="MessagePack implementation for C (runtime)"
  depends=('zlib')
  groups=('libraries')

  install -d -m755 ${pkgdir}/usr/bin
  install -m755 ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin/

  # license
  install -d -m755 ${pkgdir}/usr/share/licenses/${pkgname}/
  install -m644 ${srcdir}/msgpack-c/{COPYING,LICENSE*} ${pkgdir}/usr/share/licenses/${pkgname}/
}

package_msgpack-c-devel() {
  pkgdesc="MessagePack implementation for C (headers & libraries)"
  depends=('zlib-devel')
  groups=('development')

  install -d -m755 ${pkgdir}/usr/include
  cp -rf ${srcdir}/dest/usr/include/* ${pkgdir}/usr/include/

  install -d -m755 ${pkgdir}/usr/lib
  cp -rf ${srcdir}/dest/usr/lib/* ${pkgdir}/usr/lib/
}
